from flask import Blueprint,jsonify, request
from main.BSL.medicineBSL import *
from main.utils import InterfaceHelper,RequestHelper

medicine = Blueprint('medicine',__name__)

@medicine.route('/medicine/', methods=["POST"])
def medicine_ask():
    res = {}
    dic = RequestHelper.formToDict(request)
    is_exist = query_warning(dic['name'])
    if is_exist:
        res = is_exist.to_json()
    else:
        res['warning'] = "none"
    return jsonify(res)



@medicine.route('/medicine/all', methods=["GET"])
def medicine_get():
    res = {}
    data = []
    for i in query_all():
        data.append(i.to_json())
    res['medicines'] = data
    res['status'] = 1
    return jsonify(res)